package inabit.inabitcompiler.productions.variable;

import inabit.compiler.parser.grammar.NonTerminal;
import inabit.compiler.parser.grammar.Production;
import inabit.compiler.parser.grammar.Symbol;
import inabit.compiler.parser.grammar.Terminal;
import inabit.inabitcompiler.lexical.InabitTokenClass;
import inabit.inabitcompiler.parser.InabitSemanticAction;

/**L -> idL'*/
/**@author Rafael Rocha*/
public class L_Rule extends Production{
	private Terminal id;
	private NonTerminal L1;
	
	public L_Rule() {
		super("L");
	}

	@Override
	protected Symbol[] production(final NonTerminal nonTerminal) {
		id = new Terminal(InabitTokenClass.ID);
		L1 = new NonTerminal("L'");
		Symbol[] symbols = {
				id,
				L1,
				new InabitSemanticAction(nonTerminal){

					@Override
					public void execute() throws Exception {
						nonTerminal.code = id.getValue() + L1.code;
					}
					
				}
		};
		return symbols;
	}
}
